package leecode

func fileCombination(target int) (result [][]int) {
	left, right := 1, 2
	sum := left + right
	for left <= right {
		if sum == target {
			temp := make([]int, 0)
			for i := left; i <= right; i++ {
				temp = append(temp, i)
			}
			if len(temp) >= 2 {
				result = append(result, temp)
			}
			right++
			sum = sum + right
		} else if sum < target {
			//sum < target , 窗口继续右移
			right++
			sum = sum + right
		} else {
			// sum > right , 窗口左边界右移 右边界停止
			sum = sum - left
			left++
		}
	}
	return result
}
